package com.bank.api.model;

import lombok.Data;

import java.io.Serializable;

@Data
public class AmountExchange implements Serializable {

    private Long userId;

    private Long exchangeAmount;

    private PriceUnit from;

    private PriceUnit to;

    private String trxRecordNo;


    public Long exchange() {
        if (from == PriceUnit.DOLLAR && to == PriceUnit.RMB) {
            return exchangeAmount * 7;
        }
        if (from == PriceUnit.RMB && to == PriceUnit.DOLLAR) {
            return exchangeAmount / 7;
        }
        if (from == to) {
            return exchangeAmount;
        }
        return null;
    }

}
